package ui {
	import flash.utils.Dictionary;
	import flash.events.KeyboardEvent;
	import flash.display.Stage;
	/**
	 * @author jao
	 */
	public class KeyboardController {
		private var keys:Dictionary;
		public function KeyboardController(stage:Stage){
			keys = new Dictionary();
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyListener);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyListener);
		}

		private function keyListener(event : KeyboardEvent) : void {
			keys[event.keyCode] = (event.type == KeyboardEvent.KEY_DOWN);
		}
		
		public function isDown(keyCode:uint):Boolean{
			return keys[keyCode];
		}
	}
}
